home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 50
/
Volume 50 - JOGO DISK .iso
/
Games
/
moonstonemadness.swf
/
scripts
/
__Packages
/
Library
/
Utils
/
MoreMath.as
< prev
next >
Wrap
Text File
|
2007-09-27
|
2KB
|
88 lines
class Library.Utils.MoreMath
{
function MoreMath()
{
}
static function getRandomRange(__nMin, __nMax)
{
return Math.floor(Math.random() * (__nMax + 1 - __nMin)) + __nMin;
}
static function getPolarity(__nNum)
{
var _loc1_ = 0;
if(__nNum < 0)
{
_loc1_ = -1;
}
else if(__nNum > 0)
{
_loc1_ = 1;
}
return _loc1_;
}
static function getReachZero(__nNum, __nReducer)
{
return Library.Utils.MoreMath.getReachNum(__nNum,0,__nReducer);
}
static function getReachNum(__nNum, __nTargetNum, __nReducer)
{
var _loc1_ = __nNum;
if(_loc1_ != __nTargetNum)
{
if(_loc1_ < __nTargetNum)
{
_loc1_ += __nReducer;
if(_loc1_ > __nTargetNum)
{
_loc1_ = __nTargetNum;
}
}
else
{
_loc1_ -= __nReducer;
if(_loc1_ < __nTargetNum)
{
_loc1_ = __nTargetNum;
}
}
}
return _loc1_;
}
static function getDistance(__nX1, __nY1, __nX2, __nY2)
{
return Math.sqrt(Math.pow(Math.abs(__nX2 - __nX1),2) + Math.pow(Math.abs(__nY2 - __nY1),2));
}
static function getHypotenuse(__nDX, __nDY)
{
return Math.sqrt(Math.pow(__nDX,2) + Math.pow(__nDY,2));
}
static function getAngle(__nX1, __nY1, __nX2, __nY2)
{
var _loc2_ = undefined;
var _loc1_ = undefined;
var _loc4_ = undefined;
var _loc3_ = undefined;
_loc2_ = __nX2 - __nX1;
_loc1_ = __nY2 - __nY1;
_loc4_ = Math.atan2(_loc1_,_loc2_);
_loc3_ = Library.Utils.MoreMath.getDegreeFromRadius(_loc4_);
return _loc3_;
}
static function getDegreeFromRadius(__nRadius)
{
var _loc1_ = __nRadius / 3.141592653589793 * 180;
return _loc1_;
}
static function getRadianFromDegree(__nDegree)
{
var _loc1_ = __nDegree * 0.017453292519943295;
return _loc1_;
}
static function getBoundsCenter(_oBox)
{
var _loc3_ = (_oBox.xMin + _oBox.xMax) / 2;
var _loc2_ = (_oBox.yMin + _oBox.yMax) / 2;
return {x:_loc3_,y:_loc2_};
}
}